using System;

using NewtonDynamics;


namespace NewtonDynamics
{
	public partial class CMaterial
	{
		#region Members

		protected CWorld m_World;
		public CWorld World { get { return m_World; } }

		protected int m_ID;
		public int ID { get { return m_ID; } }

		private IntPtr m_Handle;
		internal IntPtr Handle { get { return m_Handle; } }

		#endregion


		#region Constructor

		public CMaterial(CWorld pWorld, IntPtr pHandle)
		{
			m_World = pWorld;
			m_Handle = pHandle;
		}


		public CMaterial(CWorld pWorld, bool pDefaultGroup)
		{
			m_World = pWorld;

			if(pDefaultGroup)
			{
				m_ID = GetDefaultGroupID();
			}
			else
			{
				m_ID = CreateGroupID();
			}

			CHashTables.Material.Add(m_ID, this);
		}

		#endregion


		#region Methods

		private int GetDefaultGroupID()
		{
			return Newton.NewtonMaterialGetDefaultGroupID(m_World.Handle);
		}

		private int CreateGroupID()
		{
			return Newton.NewtonMaterialCreateGroupID(m_World.Handle);
		}

		public void Dispose()
		{
			Newton.NewtonMaterialDestroyAllGroupID(m_World.Handle);

			CHashTables.Material.Remove(m_ID);
		}

		#endregion
	}
}

		

	
		


		


		
